package com.reebake.ideal.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.reebake.ideal.infra.client.ContentClobClient;
import com.reebake.ideal.infra.entity.ContentClobDTO;
import com.reebake.ideal.system.entity.Notice;
import com.reebake.ideal.system.service.NoticePlusService;
import com.reebake.ideal.system.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NoticePlusServiceImpl implements NoticePlusService {
    @Autowired
    private ContentClobClient contentClobClient;
    @Autowired
    private NoticeService noticeService;

    @Override
    public void save(Notice notice, String content) {
        if(StrUtil.isNotBlank(content)){
            ContentClobDTO contentClob = new ContentClobDTO();
            contentClob.setContent(content);
            contentClob.setContentClobId(notice.getContentClobId());
            contentClobClient.saveOrUpdate(contentClob);
            notice.setContentClobId(contentClob.getContentClobId());
        }
        noticeService.saveOrUpdate(notice);
    }
}
